package domain;

import com.alibaba.fastjson.JSONObject;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 * @ClassName DEMO
 * @description: TODO
 * @date 2024年05月13日
 * @version: 1.0
 */
public class DEMO {
    public static void main(String[] args) {


        int index = 0;
        JSONObject jsonObject = new JSONObject();
        Map<String, Object> map = new HashMap<>();
        BufferedReader readerDataFile=null;
        String line="";
        try {
            Map<String,String> mapData = new HashMap<>();
             readerDataFile = new BufferedReader(new FileReader("C:/DATA111.csv"));
            while ((line = readerDataFile.readLine()) != null) {
                String []userArr=line.split(",");
                mapData.put(userArr[2],userArr[0]);
            }

/*            File file = new File("\\\\10.0.10.36\\ren_lian_bak\\PeopleImg_test");
            File files[]=file.listFiles();
            for(File oldFile:files){
                File newFile = new File("\\\\10.0.10.36\\ren_lian_bak\\PeopleImg_test\\"+mapData.get(oldFile.getName()));
                if (oldFile.renameTo(newFile)) {
                    System.out.println("文件重命名成功！");
                } else {
                    System.out.println("文件重命名失败！");
                }
            }*/

            File file = new File("\\\\10.0.10.36\\ren_lian_bak\\PeopleImg_test");
            File files[]=file.listFiles();
            for(File oldFile:files){
              //  System.out.println(oldFile.getName());
                File filesuser[]=oldFile.listFiles();
                if(filesuser!=null&&filesuser.length>0){

                        File file1 = filesuser[0];
                        String fileName[]=filesuser[0].getName().split("_");
                         File file2 = new File(oldFile+"/"+oldFile.getName()+"_"+fileName[1]);

                        if (file1.renameTo(file2)) {
                            System.out.println("文件重命名成功！");
                        } else {
                            System.out.println("文件重命名失败！");
                        }
                }
            }



        } catch (IOException e) {
            throw new RuntimeException(e);
        }finally {
            try {
                readerDataFile.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }


    }
}
